import { OnGatewayConnection, SubscribeMessage, WebSocketGateway, WebSocketServer } from "@nestjs/websockets";
import { Server } from "ws";
import type { WebSocket } from "ws";
@WebSocketGateway({
  path: "ws-demo",
})
export class WsDemoGateway {
  @SubscribeMessage("ping")
  handleMessage() {
    return "pong";
  }
}

// @WebSocketGateway({ path: "ws-demo" })
// export class WsDemoGateway implements OnGatewayConnection {
//   @WebSocketServer()
//   server: Server;

//   handleConnection(client: WebSocket) {
//     client.on("message", (data: string) => {
//       const msg = JSON.parse(data);
//       if (msg.type === "ping") {
//         client.send(JSON.stringify({ type: "pong" }));
//       }
//     });
//   }
// }
